package com.sgb.kjwl.view.ui.adapter.search;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;

import androidx.core.util.Pair;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemMaterialGoodsBinding;
import com.sgb.kjwl.model.entity.user.GoodsListEntity;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.TextViewBindingAdapter;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * @author Administrator
 */
public class RecommendMaterialAdapter extends BaseRecycleAdapter<GoodsListEntity> {


    public RecommendMaterialAdapter(Context context, List<GoodsListEntity> datas) {
        super(context, R.layout.item_recommend_goods_item, datas);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void convert(ItemViewHolder holder, final GoodsListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemMaterialGoodsBinding itemMaterialGoodsBinding = (ItemMaterialGoodsBinding) holder.getmBinding();
        itemMaterialGoodsBinding.contentView.setOnClickListener(v -> ActivityJump.jumpToActivity(context,ShopInfoForCompanyTradesActivity.class, Pair.create("id",entity.getShopId())));

        if (entity.getPromoteStatus() == 2){
            itemMaterialGoodsBinding.imgCx.setVisibility(View.VISIBLE);
            itemMaterialGoodsBinding.tvLastPrice.setVisibility(View.VISIBLE);
            itemMaterialGoodsBinding.tvLastPrice.setText(entity.getPromotePrice());
            TextViewBindingAdapter.setNoddleLine(entity.getPromotePrice());
        }else {
            itemMaterialGoodsBinding.imgCx.setVisibility(View.GONE);
            itemMaterialGoodsBinding.tvLastPrice.setVisibility(View.GONE);
        }
    }


}
